import edu.rit.ds.Lease;
import edu.rit.ds.RemoteEventListener;
import edu.rit.ds.registry.NotBoundException;

import java.rmi.Remote;
import java.rmi.RemoteException;

/**
 * @author Alan Kaminsky
 * @source P2Pedia example
 * 
 * @contributor Praneeth Pulusani
 * Interface MQServerRef specifies the Java RMI remote interface for a distributed
 * MQServer object in the Message Queuing system.
 */
public interface MQServerRef
	extends Remote
	{
	/**
	 * Forward the message from sender to receiver.
	 * If the MQ server can't forward the message to the receiver 
	 * -- for example, if no receiver with the receiver ID exists, 
	 * or if there was a communication error while trying to forward the message 
	 * -- the MQ server adds the message to a first-in-first-out (FIFO) queue 
	 * associated with the receiver ID.
	 * If the MQ server can forward the message to the receiver, the MQ server does so, 
	 * and the message does not go into the queue.
	 * 
	 * @param senderID - ID of the sender
	 * @param reciverID - Place where message is going to
	 * @param Message - message that is being transported
	 * 
	 * @throws NotBoundException
	 * 
	 * @exception RemoteException
	 *                Thrown if a remote error occurred.
	 */
	public void sendMessage
		(int senderID, int receiverID, String message)
		throws RemoteException, NotBoundException;


	/**
	 * Add the given remote event listener to this MQServer. Whenever a message is
	 * passed through to this server, this server will report a MQserverEvent to the given
	 * listener.
	 * 
	 * @param listener
	 *            Remote event listener.
	 */
	public Lease addListener
		(RemoteEventListener<MQServerEvent> listener)
		throws RemoteException;
	}
